﻿<?php
session_start();

// Martin Laas - kursus1109

echo
$_SESSION['guess'][] = $_POST['guess'];
 if (!$_SESSION['ans']) {
        $_SESSION['rand']=rand(1,1000);
        $_SESSION['ans']=true;
         }
if ($_POST['guess']>$_SESSION['rand']){
         $msg= "Arv on vaiksem";
 }
 elseif ($_POST['guess']<$_SESSION['rand']){
        $msg="Arv on suurem";
 }
 
 else {
        $msg="Õige. Mängi uuesti!";
        $_SESSION['ans']=false;
 }
?>
<html>
<head>
<center>

<p> <?php echo $msg."<br>"; ?> </p>
<form method="post">

 

<input type="text" name="guess" />
<input type="submit" value="Paku" />
 <input type="submit" value="Uus mäng" />

</form>
</center>
</body>
</html>
<?php
print_r($_SESSION['guess']);
?>